<?
require("adm_header.php"); 
writeCommonAdminTable(LA_ADMIN_BLOCK,1);
$lTableBlock=$set_table_prefix . "block";


// ## Set up tables
$lSQL="CREATE TABLE IF NOT EXISTS $lTableBlock (
`bl_id` INT NOT NULL AUTO_INCREMENT ,
`bl_email` VARCHAR( 255 ) ,
`bl_ip` VARCHAR( 255 ) ,
`bl_reason` VARCHAR( 255 ) ,
`bl_num_attempt` INT DEFAULT 0,
PRIMARY KEY ( `bl_id` ))";
q($lSQL);
?>

<p><b><? echo LA_ADMIN_BLOCK ?></b></p>
<img src="../layout_images/add.gif" align="left" hspace="10"><a href='?create_new=1'><? echo LA_ADMIN_BLOCK_CREATE ?></a>
<?

if (getParam("create_new","") || getParam("user_name",""))
{
	if (getParam("user_name",""))
		q("insert into $lTableBlock (bl_email) values ('".getParam("user_name","")."')");	
	else 
		q("insert into $lTableBlock (bl_reason) values ('')");
}
if (getParam("del",""))
	q("delete from $lTableBlock where bl_id=" . getParam("del",""));	

if (getParam("id",""))
{
	$sql = "update $lTableBlock set bl_email='" . getParam("user","")  . "', bl_ip='" . getParam("ip","")  . "',bl_reason='" . getParam("block_reason","")  . "' where bl_id=" . getParam("id","");
	q($sql);
}
	

$sql= "select * from $lTableBlock";
$res=q($sql);

echo "<p></p><table width=\"100%\" cellpadding=\"0\" cellspacing=\"0\"><tr class='trHeadLine'><td>".LA_ADMIN_BLOCK_ID."</td>
<td>".LA_ADMIN_BLOCK_EMAIL."</td><td>".LA_ADMIN_BLOCK_IP."</td><td>".LA_ADMIN_BLOCK_DESCR."</td><td>".LA_ADMIN_BLOCK_NUM."</td><td>".LA_ADMIN_ACTION."</td></tr>";

if (mysql_num_rows($res)>0)
{
	while ($row=mysql_fetch_array($res))
	{
		echo "<tr><form method='post' action='adm_block.php'>";
		echo "<td><input type='hidden' name='id' value='".$row["bl_id"]."'>#".$row["bl_id"]."</td><td><input type='text' name='user' value='".$row["bl_email"]."'></td>";
		echo "<td><input type='text' name='ip' value='".$row["bl_ip"]."'></td>";
		echo "<td><input type='text' name='block_reason' value='".$row["bl_reason"]."'></td>";
	echo "<td>".$row["bl_num_attempt"]."</td>";
		echo "<td><a href='?del=".$row["bl_id"]."'><img src='../layout_images/new/delete_small.gif' border='0'  alt='Delete'></a>&nbsp;&nbsp;&nbsp;";	
		print "<input type='image' src='../layout_images/new/yes.gif' name='save' alt='".LA_ADMIN_BLOCK_SAVE."'>";
	echo "</td></form></tr>";	
	}
}
else 
{
	echo "<tr><td colspan='6'><p class='bg'>".LA_ADMIN_BLOCK_NONE."</p></td></tr>";
}
echo "</table>";
writeCommonAdminTable("Block Users","");
require "adm_footer.php"; 
?>